<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title>教练详情</title>
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<link rel="stylesheet" href="teaching2.css">
	<link rel="stylesheet" href="normalize.css">
</head>
<body>
<header>
	<button onclick="goback()"></button>
	<p class="name">加载中...</p>
	<img id="phone" class="phone" src="phone2.png" alt="phone">
</header>
<section class="main_section">
	<div class="introduce_module">
		<div class="left_head">
			<img id="teacherPhoto" src="circle2.png" alt="头像">
			<!--<p>私信Ta</p>-->
		</div>
		<div class="right_text">
			<div class="location">
				<p>教学范围: <span id="address">点击查看<i></i></span></p>
			</div>
			<div class="coach_info">
				<p class="content">加载中...</p>
			</div>
			<div class="choise_serve clearfix">
				<p>就近教学</p>
				<p>接送服务</p>
				<p>教练认证</p>
			</div>
		</div>
	</div>
	<div class="comment">
		<div class="coach_items clearfix">
			<p>车型任选</p>
			<p>金牌教练</p>
			<p>老司机</p>
			<p>态度好</p>
		</div>
		<div class="public_comments clearfix">
			<div class="conments_left">
				<h4>最新评论</h4>
				<p>暂无</p>
			</div>
			<!--<div class="conments_more" onclick = 'window.location.href="pingjia.html"'>
				<span >更多评论<i></i></span>
			</div>-->
		</div>
	</div>
	<div class="subject_time">
		<div class="headline clearfix">
			<ul class="clearfix">
				<li name='appointment_time2' place="place2" subject="two" class="active_headline">科二</li>
				<li name='appointment_time3' place="place3"  subject="three">科三</li>
			</ul>
		</div>
		<div class="appointment_time2 clearfix appointment_time">
			<ul class="teach_time clearfix">
				<li class="time_slot clearfix">
					<ul class="clearfix">
						<li>时间段</li>
						<li>07:00~08:00</li>
						<li>08:20~09:20</li>
						<li>09:40~10:40</li>
						<li>11:00~12:00</li>
						<li>12:20~13:20</li>
						<li>13:40~14:40</li>
						<li>15:00~16:00</li>
						<li>16:20~17:20</li>
						<li>17:40~18:40</li>
					</ul>
				</li>
				<li class="tomorrow today clearfix">
					<ul class="clearfix"  id="today" >
						<li>今天</li>
						<li class="t1">
							<form>
								<label>
									<input class="check1" type="checkbox" value="1" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t2">
							<form>
								<label>
									<input class="check1" type="checkbox" value="2" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t3">
							<form>
								<label>
									<input class="check1" type="checkbox" value="3" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t4">
							<form>
								<label>
									<input class="check1" type="checkbox" value="4" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t5">
							<form>
								<label>
									<input class="check1" type="checkbox" value="5" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t6">
							<form>
								<label>
									<input class="check1" type="checkbox" value="6" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t7">
							<form>
								<label>
									<input class="check1" type="checkbox" value="7" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t8">
							<form>
								<label>
									<input class="check1" type="checkbox" value="8" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li class="t9">
							<form>
								<label>
									<input class="check1" type="checkbox" value="9" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
					</ul>
				</li>
					<li class="tomorrow today clearfix">
					<ul class="clearfix" id="tomorrow">
						<li>明天</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="1" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="2" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="3" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="4" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="5" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="6" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="7" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="8" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="9" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
					</ul>
				</li>
				<li class="after_tomorrow today  clearfix">
					<ul class="clearfix" id="after">
						<li>后天</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="1" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="2" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="3" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="4" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="5" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="6" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="7" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="8" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
						<li>
							<form>
								<label>
									<input class="check1" type="checkbox" value="9" name="checkbox" ><i></i>
								</label>
							</form>
						</li>
					</ul>
				</li>
			</ul>
		</div>
	</div>
	<div class="time_frame_ul_li submit-final1">
		<button id="submit" class="submit-final">提交</button>
	</div>
</section>
<input type="hidden" id="subject" value="two">
<input type="hidden" id="place2" value="">
<input type="hidden" id="place3" value="">
<input type="hidden" id="place" value="">
<script src="./jquery.min.js"></script>
<script src="./picturefill.js"></script>
<script src="./index.js"></script>
<script src="../layer.js"></script>
<script>

function goback(){

	history.back();
}
	$(function () {
		var mydate = new Date();
		var h =mydate.getHours();
		var m=mydate.getMinutes();
		var time=h+m/60;
		if(time>=7 && time<8){
			$('.t1').html('<p>关闭</p>');
		}
		else if(time>=8.33 && time<=9.33){
			for(var i=1;i<=2;i++){
				$('.t'+i).html('<p>关闭</p>');
			}
		}
		else if(time>=9.66 && time<=10.66){
			for(var i=1;i<=3;i++){
				$('.t'+i).html('<span>关闭</span>');
			}
		}
		else if(time>=11 && time<=12){
			for(var i=1;i<=4;i++){
				$('.t'+i).html('<span>关闭</span>');
			}
		}
		else if(time>=12.33 && time<=13.33){
			for(var i=1;i<=5;i++){
				$('.t'+i).html('<span>关闭</span>');
			}
		}
		else if(time>=13.66 && time<=14.66){
			for(var i=1;i<=6;i++){
				$('.t'+i).html('<span>关闭</span>');
			}
		}
		else if(time>=15 && time<=16){
			for(var i=1;i<=7;i++){
				$('.t'+i).html('<span>关闭</span>');
			}
		}
		else if(time>=16.33 && time<=17.33){
			for(var i=1;i<=8;i++){
				$('.t'+i).html('<span>关闭</span>');
			}
		}
		else if(time>=17.66){
			for(var i=1;i<=9;i++){
				$('.t'+i).html('<span>关闭</span>');

			}
		}

		var url = localStorage.icandriveUrl;
		var token =localStorage.phone;
		var teacher_id =localStorage.teacher_id;
		$.ajax({
			url:"https://newapp.icandrive.cn/api/teacherInfo.php",
			type:'post',
			data:{token:token,teacher_id:teacher_id},
			dataType:'json',
			success:function(data){
				if(data.status==200){
					$('#teacherPhoto').prop('src',data.teacher.teacher_photo);
					$('#teacherPhoto').on('click', function () {
						window.location.href='sms://'+data.teacher.phone;
					});
					$('#phone').on('click', function () {
						window.location.href='tel://'+data.teacher.phone;
					});
					$('#address').on('click', function () {
						localStorage.gpsj=data.teacher.gps_j;
						localStorage.gpsw=data.teacher.gps_w;
						window.location.href='../teaching/distence.html';
					});

                    	localStorage.teacher_name=data.teacher.teacher_name;
                              	localStorage.teacher_phone=data.teacher.phone;
					$('.name').html(data.teacher.teacher_name);
					$('.content').html(data.teacher.autograph);
					$('#place').val(data.teacher.subject2_place);
					$('#place2').val(data.teacher.subject2_place);
					$('#place3').val(data.teacher.subject3_place);
					$(data.time).each(function(){
						                    var start=new Date();
        start.setHours(0);
        start.setMinutes(0);
        start.setSeconds(0);
        start.setMilliseconds(0);
        var str=Date.parse(start)/1000;
						var timestamp='';
						if(this.clear_date){
							timestamp = Date.parse(this.clear_date)/1000;
						}else{
							timestamp = Date.parse(this.order_time)/1000;
						}
						var data=(timestamp-str)/3600/24;

						if(data>=0 && data<1){//代表今天
							$('#today li').eq(this.time_id).html('<span>关闭</span>');
						}
						if(data>=1 && data<2){//代表明天
							$('#tomorrow li').eq(this.time_id).html('<span>关闭</span>');
						}
						if(data>=2 && data<3){//代表后天
							$('#after li').eq(this.time_id).html('<span>关闭</span>');
						}
					});
				}
				if(data.status==250){
					layer.msg("请重新登录");
					setInterval(function(){
						window.location.href="../login/log_in.html";
					},2000)
				}
				if(data.status==400){
					layer.msg(data.msg);
					setInterval(function(){
						history.back()
					},2000)
				}
			}

		});
	$('#submit').on('click',function(){

		var today=[];
		var tomorrow=[];
		var after=[];


		$('#today input').each(function () {
			if($(this).prop('checked')){
				today.push($(this).val());
			}
		})
		$('#tomorrow input').each(function () {
			if($(this).prop('checked')){
				tomorrow.push($(this).val());
			}
		})
		$('#after input').each(function () {
			if($(this).prop('checked')){
				after.push($(this).val());
			}
		});

		if(today.length==0 && tomorrow.length==0 && after.length==0){
			layer.msg('请先选择一个时间段')
			return false;
		}
		var url= window.location.search;
		if(url!=''){

		var type=url.split('?')[1];
		var type2=type.split('=')[1];
		// var type=localStorage.sendtype;

		 // var url=searchurl();
		}

		var sendteacher=localStorage.sendteacher;

		var subject=$('#subject').val();
		var place=$('#place').val();
		var address='';
		if(type2=='date'){
			if(today.length+tomorrow.length+after.length!=1){
				layer.msg('只能选择一个时间段')
				return false;
			}


			var name = prompt("请输入您的地理位置", ""); //将输入的内容赋给变量 name ，
			//这里需要注意的是，prompt有两个参数，前面是提示的话，后面是当对话框出来后，在对话框里的默认值
			if (name)//如果返回的有内容
			{
				address=name;
				if(today=='' && tomorrow=='' && after==''){
					layer.msg('请选择时间')
				}
				else{
					$.ajax({
						url:'http:https://newapp.icandrive.cn/api/songkao.php',
						data:{token:token,address:address,teacher_id:sendteacher,today:today,tomorrow:tomorrow,after:after,subject:subject},
						type:'post',
						dataType:'json',
						success: function (data) {
							console.log(data);
							if(data.status==200){

							layer.msg('预约成功')

							}
							else{
								console.log(data);
							}
						},
						error: function () {
							 layer.msg('系统维护中',function(){
                                history.go(0)
                            },1000);
						}
					})
				}

			}else{
				alert('请输入地址')
			}

		}
		else{

			localStorage.teacher_id=teacher_id;
			localStorage.today=today;
			localStorage.tomorrow=tomorrow;
			localStorage.after=after;
			localStorage.subject=subject;
			localStorage.place=place;
			window.location.href="../info/yuejiao.html"
		}
	})


})
</script>

    <script>
    document.addEventListener("plusready", function() {
        // 注册返回按键事件
        plus.key.addEventListener('backbutton', function() {
            window.history.back();
        }, false);
        //此处false代表不退出页面，如果为true回退到上一个一面
    });
</script>
</body>
</html>
